#    Copyright 2011 Tri-County Electric Cooperative, St. Matthews, South Carolina
#    This file is part of COOPWeb.
#    COOPWeb is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPWeb is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPWeb.  If not, see <http://www.gnu.org/licenses/>.

import os
import datetime
import shutil

#************************BEGIN Add Include Files to Path************************
import sys
NeededPaths=['/opt/coopweb/djangoproject/include', '/opt/coopweb/djangoproject']
for path in NeededPaths:
    if(not path in sys.path):
        sys.path.append(path)
#************************END   Add Include Files to Path************************
from django.contrib.gis.geos import *
import os, time, psycopg2, datetime
#********************Setup psycopg2 and django section********************
PathDjangoRoot="/opt/coopweb/"
if(not PathDjangoRoot in sys.path):
    sys.path.append(PathDjangoRoot)
from django.core.management import setup_environ
import djangoproject
from djangoproject import settings
setup_environ(settings)
from models import *
#********************Setup psycopg2 and django section********************

from django.template import Context, loader
from django.http import HttpResponse
from django import forms
import os
import datetime
import djangoproject.settings
import COOPWeb_Misc, COOPWeb_Form
from django.contrib.gis.geos import *




def BuildMeterPingForm(SpecialBuildFormDataDict):
    Dict={}
    Dict['MeterNumberList']=forms.CharField(required=False, widget=forms.TextInput(attrs={'size':'50'}))
    return Dict


def ProcessMeterPingForm(form, Username, request):
    MeterNumberList=COOPWeb_Form.FormGetList(form, 'MeterNumberList')
    for meterNumber in MeterNumberList:
        CommunicationCommand().CreatePingMeterCommand(meterNumber, Username)
    return MeterNumberList




def PopulateMeterPingForm(form):
    form.data['MeterNumberList']=''
    return form






